import {
  http
} from '@/utils/request';
import store from '@/store'
import mTypes from '@/store/mutationsTypes'
// 验证码

export const sendSms = async (data) => {
  let res = await http.post({
    url: '/sms/sendmsg',
    data
  })
  return res
}

export const checkSms = async (data) => {
  let res = await http.post({
    url: '/sms/check',
    data
  })
  return res
}

export const fetchHomeCarousel = async (data) => {
  let res = await http.post({
    url: '/commononline/carousel',
    data
  })
  return res
}

export const fetchGrade = async (data) => {
  let res = await http.post({
    url: '/user/getgrade',
    data
  })
  return res
}

export const checkShopCode = async (data) => {
  let res = await http.post({
    url: '/user/checkorgbycode',
    data
  })
  return res
}
export const fetchCourse = async (data) => {
  let res = await http.post({
    url: '/useronline/getcourse',
    data
  })
  return res
}
export const fetchdoubleCourse = async (data) => {
    let res = await http.post({
        url: '/useronline/getdoublecourse',
        data
    })
    return res
}
export const placeOrder = async (data) => {
    let res = await http.post({
        url: '/index/packageRenewal',
        data
    })
    return res
}
export const checkOrder = async (data) => {
    let res = await http.post({
        url: '/index/checkorder',
        data
    })
    return res
}
export const fastLogin = async (data) => {
  let res = await http.post({
    url: '/useronline/fastlogin',
    data
  })
  if (res.code === 1) {
    store.commit(mTypes.userInfo, res.data)
  }
  return res
}

export const userLogin = async (data) => {
  let res = await http.post({
    url: '/useronline/login',
    data
  })
  if (res.code === 1) {
    store.commit(mTypes.userInfo, res.data)
  }
  return res
}

export const assignLogin = async (data) => {
  let res = await http.post({
    url: '/useronline/assistlogin',
    data
  })
  if (res.code === 1) {
    store.commit(mTypes.userInfo, res.data)
  }
  return res
}
/**
 * @mobile
 * @password
 * @repassword
 * @code
 *
 * @param {*} data
 */
export const register = async (data) => {
  let res = await http.post({
    url: '/useronline/register',
    data
  })
  return res
}

export const resetPasswd = async (data) => {
  let res = await http.post({
    url: '/user/password',
    data
  })
  return res
}

export const teacherResetPasswd = async (data) => {
  let res = await http.post({
    url: '/useronline/password',
    data
  })
  return res
}

/**
 * @name
 * @sex
 * @grade
 * @school
 * @org_id
 * @param {*} data
 */
export const setPersonal = async (data) => {
  let res = await http.post({
    url: '/useronline/personal',
    data
  })
  return res
}

export const changePhone = async (data) => {
  let res = await http.post({
    url: '/usercenter/changemobile',
    data
  })
  return res
}

/**
 * type int  required 0 学生 1 老师
 * show_type int required 0 时间轴 1 日历
 * @param {*} data
 */
export const fetchTimetable = async (data) => {
  let res = await http.post({
    url: '/useronline/timetable',
    data
  })
  return res
}

/**
 *
 * @param {*} data
 */

 export const fetchCalendar = async (data) => {
   let res = await http.post({
     url: '/useronline/tablecalendar',
     data
   })
   return res
 }

// 用户协议

export const fetchRegister = async (data) => {
  let res = await http.post({
    url: '/useronline/registration',
    data
  })
  return res
}

export const fetchPrivacy = async (data) => {
  let res = await http.post({
    url: '/useronline/privacyprotection',
    data
  })
  return res
}

export const postForm = async (url, data) => {
  let res = await http.post({
    url: url,
    data
  })
  return res
}

export const getForm = async (url, params) => {
  let res = await http.get({
    url: url,
    params
  })
  return res
}

// 课程详情
export const courseDetail = async (data) => {
  let res = await http.post({
    url: '/usercenter/courseinfo',
    data
  })
  return res
}

// 下单
export const coursePay = async (data) => {
  let res = await http.post({
    url: indexUrl+'/index/orderonline/placeorder',
    data
  })
  return res
}

// 上传头像
export const uploadFace = async (data) => {
  let res = await http.post({
    url: '/common/uploadonline',
    data
  })
  return res
}

// 课程评价
export const getappRaise = async (data) => {
  let res = await http.post({
    url: '/usercenter/getappraise',
    data
  })
  return res
}
// 检测学生状态
export const checkUserStatus = async (data) => {
  let res = await http.post({
    url: '/useronline/checkUserStatus',
    data
  })
  return res
}
//获取测评单词
export const getExamwords = async (data) => {
  let res = await http.post({
    url: '/exam/getwords',
    data
  })
  return res
}
//获取听力单词
export const getlistenWords = async (data) => {
  let res = await http.post({
    url: '/exam/getlistenwords',
    data
  })
  return res
}
//提交报告
export const getReport = async (data) => {
  let res = await http.post({
    url: '/exam/examonlineupresult',
    data
  })
  return res
}
//获取报告
